home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / libs / unixlib.lha / unix / src / error.c < prev    next >
C/C++ Source or Header  |  1996-08-12  |  2KB  |  77 lines

  1. #include "amiga.h"
  2.  
  3. int __near errno;
  4.  
  5. int convert_oserr(int ioerr)
  6. {
  7.     extern int _OSERR;
  8.  
  9.     _OSERR = ioerr;
  10.     switch (ioerr) {
  11.     case 0:
  12.         return 0;
  13.     case ERROR_NO_FREE_STORE:
  14.         return ENOMEM;
  15.     case ERROR_TASK_TABLE_FULL:
  16.         return EAGAIN;
  17.     case ERROR_BAD_TEMPLATE:
  18.     case ERROR_REQUIRED_ARG_MISSING:
  19.     case ERROR_BAD_NUMBER:
  20.     case ERROR_KEY_NEEDS_ARG:
  21.     case ERROR_TOO_MANY_ARGS:
  22.     case ERROR_UNMATCHED_QUOTES:
  23.         return EINVAL;
  24.     case ERROR_LINE_TOO_LONG:
  25.         return E2BIG;
  26.     case ERROR_FILE_NOT_OBJECT:
  27.         return ENOEXEC;
  28.     case ERROR_OBJECT_IN_USE:
  29.         return EBUSY;
  30.     case ERROR_OBJECT_EXISTS:
  31.         return EEXIST;
  32.     case ERROR_DIR_NOT_FOUND:
  33.         return ENOENT;
  34.     case ERROR_OBJECT_NOT_FOUND:
  35.         return ENOENT;
  36.     case ERROR_BAD_STREAM_NAME:
  37.         return EINVAL;
  38.     case ERROR_OBJECT_TOO_LARGE:
  39.         return E2BIG;
  40.     case ERROR_ACTION_NOT_KNOWN:
  41.         return EINVAL;
  42.     case ERROR_INVALID_COMPONENT_NAME:
  43.         return ENAMETOOLONG;
  44.     case ERROR_INVALID_LOCK:
  45.         return EINVAL;
  46.     case ERROR_OBJECT_WRONG_TYPE:
  47.         return EINVAL;
  48.     case ERROR_DISK_WRITE_PROTECTED:
  49.         return EROFS;
  50.     case ERROR_RENAME_ACROSS_DEVICES:
  51.         return EXDEV;
  52.     case ERROR_DIRECTORY_NOT_EMPTY:
  53.         return ENOTEMPTY;
  54.     case ERROR_TOO_MANY_LEVELS:
  55.         return ELOOP;
  56.     case ERROR_DEVICE_NOT_MOUNTED:
  57.         return ENODEV;
  58.     case ERROR_SEEK_ERROR:
  59.         return EINVAL;
  60.     case ERROR_DISK_FULL:
  61.         return ENOSPC;
  62.     case ERROR_DELETE_PROTECTED:
  63.         return EACCES;
  64.     case ERROR_WRITE_PROTECTED:
  65.         return EACCES;
  66.     case ERROR_READ_PROTECTED:
  67.         return EACCES;
  68.     default:
  69.         return EOSERR;
  70.     }
  71. }
  72.  
  73. void _seterr(void)
  74. {
  75.     errno = convert_oserr(IoErr());
  76. }
  77.